package com.itheima.app.controller;

import com.itheima.app.manager.SettingManager;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author 请不要叫我高司令
 * @Date 2022/3/14 23:41
 * @Version 1.0
 */

@RestController
public class SettingController {

    @Autowired
    private SettingManager settingManager;

    @GetMapping("/users/settings")
    public ResponseEntity settings() {

        return settingManager.settings();

    }

    // 发送验证码
    @PostMapping("/users/phone/sendVerificationCode")
    public void sendVerificationCode() {
        settingManager.sendVerificationCode();
    }


    //校验验证码
    @PostMapping("/users/phone/checkVerificationCode")
    public ResponseEntity checkVerificationCode(@RequestBody Map<String, String> param) {

        String verificationCode = param.get("verificationCode");

        return settingManager.checkVerificationCode(verificationCode);
    }

    //设置手机号
    @PostMapping("/users/phone")
    public void updatePhone(@RequestBody Map<String,String> map) {
        String phone = map.get("phone");
        settingManager.updatePhone(phone);
    }


    // 设置陌生人问题
    @PostMapping("/users/questions")
    public void setQuestion(@RequestBody Map<String, String> map) {

        String content = map.get("content");
        settingManager.setQuestion(content);

    }

    //设置消息推送通知
    @PostMapping("/users/notifications/setting")
    public void setNotification(@RequestBody Notification notificationParam) {

        settingManager.setNotification(notificationParam);

    }


    //黑名单分页查询
    @GetMapping("/users/blacklist")
    public ResponseEntity findBlackListByPage(
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) {

        return settingManager.findBlackListByPage(pageNum, pageSize);

    }


    // 删除黑名单
    @DeleteMapping("/users/blacklist/{blackUserId}")
    public void deleteBlackList(@PathVariable Long blackUserId) {

        settingManager.deleteBlackList(blackUserId);

    }

}
